﻿/*----------------------------------------------------------------
// Copyright (C) 2011 上海
// 版权所有。 
//
// 文件名：CardDeleteInfo
// 文件功能描述：卡号删除
//
// 
// 创建标识：2012-04-23 王冲
//
// 修改标识：
// 修改描述：
//
//
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DAO.WaiGaoQiao;

namespace Model.WaiGaoQiao
{
    public class CardDeleteInfo
    {
        /// <summary>
        /// 人员ID
        /// </summary>
        public int PID
        {
            get;
            set;
        }
        /// <summary>
        /// 人员编号
        /// </summary>
        public string EmpNo
        {
            get;
            set;
        }
        /// <summary>
        /// 部门名称
        /// </summary>
        public string deptName
        {
            get;
            set;
        }
        /// <summary>
        /// 人员类型
        /// </summary>
        public string PersonTypeName
        {
            get;
            set;
        }
        /// <summary>
        /// 人员姓名
        /// </summary>
        public string PName
        {
            get;
            set;
        }
        /// <summary>
        /// 卡序列号
        /// </summary>
        public Int64 CardSerial
        {
            get;
            set;
        }
        /// <summary>
        /// 卡内余额
        /// </summary>
        public decimal Balance
        {
            get;
            set;
        }
        private DataAccessCardDelete dar;
        private int CardDeletecount;
        public int _CardDeletecount
        {
            get { return CardDeletecount; }
        }
        public CardDeleteInfo(bool isgetcount)
        {
            dar = new DataAccessCardDelete();
            if (isgetcount)
            {
                CardDeletecount = GetCardDeleteCount();
            }
        }
        public CardDeleteInfo()
        { }

        /// <summary>
        /// 获取所有销卡的数量
        /// </summary>
        /// <returns></returns>
        private int GetCardDeleteCount()
        {
            return dar.GetCardDeleteCount();
        }

        /// <summary>
        /// 根据条件获取所有销卡的数量
        /// </summary>
        /// <returns></returns>
        public int GetCardDeleteCountWhere(string query)
        {
            return dar.GetCardDeleteCountWhere(query);
        }

        /// <summary>
        /// 获取部门列表（用于绑定下拉框）
        /// </summary>
        /// <returns></returns>
        public DataSet GetdeptName()
        {
            return dar.GetdeptName();
        }

        /// <summary>
        /// 获取所有销卡的信息（分页）
        /// </summary>
        /// <param name="pagesize"></param>
        /// <param name="startindex"></param>
        /// <returns></returns>
        public IList<CardDeleteInfo> SelCardDeleteInfo(int pagesize, int startindex, string strquery)
        {
            IList<CardDeleteInfo> carlist = new List<CardDeleteInfo>();
            CardDeleteInfo carinfo;
            DataSet ds = dar.SelCardDeleteInfo(pagesize, startindex, strquery);
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                carinfo = new CardDeleteInfo()
                {
                    PID = Convert.ToInt32(item["PID"]),
                    EmpNo = item["EmpNo"].ToString(),
                    deptName = item["deptName"].ToString(),
                    PersonTypeName = item["PersonTypeName"].ToString(),
                    PName = item["PName"].ToString(),
                    CardSerial = Convert.ToInt64(item["CardSerial"]),
                    Balance = Convert.ToDecimal(item["Balance"])
                };
                carlist.Add(carinfo);
            }
            return carlist;
        }

        /// <summary>
        /// 删除卡
        /// </summary>
        /// <param name="roleid"></param>
        /// <returns></returns>
        public int CardDelete(string PID, string OperatorID)
        {
            return dar.CardDelete(PID, OperatorID);
        }
    }
}
